package zero.tech.games.user.remote;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;

import zero.tech.core.data.Resp;
import zero.tech.games.api.RemoteUser;
import zero.tech.games.common.TUserAccountUtil;
import zero.tech.games.entity.user.TUser;
import zero.tech.games.entity.user.TUserAccount;
import zero.tech.games.user.mapper.TUserMapper;
import zero.tech.games.user.service.api.ITradeService;
@RestController
public class RemoteUserImpl implements RemoteUser{
	@Autowired
	private TUserMapper userMapper;
	@Autowired
	private TUserAccountUtil userAccountUtil;
	@Autowired
	private ITradeService tradeService;
	@Override
	public TUser getUser(int uid) {
		TUser user=userMapper.getUser(uid);
		return user;
	}
	@Override
	public TUserAccount getUserAccount(int uid) {
		TUserAccount userAccount = userAccountUtil.getUserAccount(uid);
		return userAccount;
	}
	@Override
	public List<TUser> getUserBatch(List<Integer> zsUids) {
		return userMapper.getUserBatch(zsUids);
	}
	@Override
	public Resp addUserDiamond(int uid, Long add_dimond, int diamond_change_type,String diamond_change_desc) {
		return tradeService.addUserDiamond(uid,add_dimond,diamond_change_type,diamond_change_desc);
	}
	@Override
	public Resp gameUpdateDiamondBatch(String order_id, int game_id, String room_id, int room_times, String room_name,
			int total_times, String diamondchangemap) {
		Map<Integer, Long> diamond_change_map = JSONObject.parseObject(diamondchangemap,new TypeReference<Map<Integer, Long>>(){});
		return tradeService.gameUpdateDiamondBatch(order_id,game_id,room_id,room_times,room_name,total_times,diamond_change_map);
	}

}
